<? include 'server_config.php'; 

if($_SESSION['user_idx'] == "")
{
	?>
	<script>
		location.href='login.php';
	</script>
	<?
	return;
}


$user_img = "./upload/member_photo/".$_SESSION['user_idx'];

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
	<title> New Document </title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="Stylesheet" type="text/css" href="./css/nddCommon.css" />
	<script type="text/javascript" src="./js/jquery-1.6.2.min.js"></script>
	<script type="text/javascript" src="./js/region.js" ></script>
	
	<script>
		function photo_preview()
		{
			//alert($('#member_photo').attr('value'));
			$('#member_info_preview').submit();
		}
		function photo_preview_done()
		{
			//alert('aa');
			$('#img_changed').val('1');
	
			$('#div_display_img').attr('src',"<? echo $user_img; ?>_temp?cache="+(Math.floor(Math.random() * 10000) + 1));
			$('#div_display_preview').show();
			page_changed();
		}
	
		function page_changed()
		{
			$('#page_changed').val('1');
	
		}
	
		$(window).bind("beforeunload", function() { 
	
			if($('#page_changed').val()=='1')
			{
				$('#page_changed').val('0');
	/*
				if(confirm('내용이 변경되었습니다. 변경내용을 저장하지 않고 페이지를 벗어나시겠습니까?'))
				{
					setTimeout( "$('#fwrite').submit();",0);
	
				}
	*/
	
			}
			
			
			
			});


	</script>	
</head>

 <body>
	<div id='wrapper'>
		<?
        include "top_menu.php";
        ?>
		
		<div id='left_bg'>
		</div>


		<div id='title'>
			<div id='title_margin_top'><span></span></div>
			<div style='width:195px;height:29px;float:left;'></div>
			<div style='width:41px;height:29px;float:left;'><img src="./img/top_icon_input.png"></div><div style='height:29px;float:left;margin-top:3px;'><span id='article_content' >계정 정보를 입력, 수정합니다.</span></div>
		</div>
		
		<?
		$current_file = basename(__FILE__);
		include 'side_menu_manage.php';
		?>

		<div id='middle_bg'>
		</div>

		<div id='document_content' style="width:776px;float:left;">
			<div style='height:2px;width:100%;background:#cccccc;float:left;'><span><span></div>
			<div style='height:3px;width:100%;float:left;'><span><span></div>

			<div style="width:714px;background:#F2F2F2;float:left;border:1px solid #E9E9E9;padding:30px;">
				<div style="width:30px;height:30px;float:left;">1</div>
				<div style="width:600px;float:left;">
					나의 사진<br>

					<?
						$sql = "
			
						INSERT INTO ndd_user_expand (user_idx) VALUES ('".$_SESSION['user_idx']."')
						";
						$result = mysql_query($sql,$connect);
					
						$sql = "
						SELECT A.nickname, A.region_1, A.region_2, B.birthday, B.sex, B.introduce
						FROM ndd_user A, ndd_user_expand B
						WHERE A.user_idx = '".$_SESSION['user_idx']."' AND A.user_idx = B.user_idx
						";
						$result = mysql_query($sql,$connect);
						$row = mysql_fetch_row($result);
			
			
					?>
	
					<form action='ndd_member_info_preview.php' method="post" enctype="multipart/form-data" id="member_info_preview" target="iframe_temp">
						<div style='width:100%;height:5px;'><span></span></div>
						<input type="file" name="member_photo" id="member_photo" onchange="photo_preview();"><br>
						<div style='width:100%;height:11px;'><span></span></div>
						
						<div style="width:50px;height:50px;background:#eeeeee;float:left;">
							
						<?
							
			
							if(file_exists($user_img)){
						?>
							<img src="<? echo $user_img; ?>?cache=<? echo rand(1000,9999); ?>" width="50px" height="50px"><br>
						<?
							}
						?>
						</div>

						<div id="div_display_preview" style="display:none;float:left;margin-left:20px;">
							<img style="width:50px;height:50px;" id="div_display_img">
						</div>
			
					</form>					
				</div>
	
		
				<iframe name="iframe_temp" style='display:none;'></iframe>
		
		
				<div style="width:100%;height:15px;float:left;"><span></span></div>

				<div style="width:100%;height:1px;background:gray;float:left;"><span></span></div>
				<div style="width:100%;height:2px;background:#ffffff;float:left;"><span></span></div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>
				<br/>

				<form name="fwrite" action="ndd_member_info_proc.php"  method="post" enctype="multipart/form-data"  id="fwrite">

				<div style="width:30px;height:30px;float:left;">2</div>
				<div style="width:600px;float:left;">
					별칭(닉네임)<br>
					<div style="width:100%;height:5px;float:left;"><span></span></div>

					<input type="text" name="member_nickname" value="<? echo $row[0];?>" onchange="$('#page_changed').val('1');"><br>
					
				
				</div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>

				<div style="width:100%;height:1px;background:gray;float:left;"><span></span></div>
				<div style="width:100%;height:2px;background:#ffffff;float:left;"><span></span></div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>
				<br/>

				<div style="width:30px;height:30px;float:left;">3</div>
				<div style="width:600px;float:left;">
					성별<br>
					<div style="width:100%;height:5px;float:left;"><span></span></div>

					<select name="member_sex" onchange="$('#page_changed').val('1');">
						<option value=""></option>
						<option value="M" <? if ($row[4]=="M") echo "selected"; ?> >남</option>
						<option value="F" <? if ($row[4]=="F") echo "selected"; ?> >여</option>
					</select>
				
				</div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>

				<div style="width:100%;height:1px;background:gray;float:left;"><span></span></div>
				<div style="width:100%;height:2px;background:#ffffff;float:left;"><span></span></div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>
				<br/>


				<div style="width:30px;height:30px;float:left;">4</div>
				<div style="width:600px;float:left;">
					생년월일<br>
					<div style="width:100%;height:5px;float:left;"><span></span></div>

					<input type="text" name="member_birth" value="<? if ($row[3]=="0000-00-00") 
							echo date('Y-m-d'); 
						else
							echo $row[3];
					?>"  onchange="$('#page_changed').val('1');"
					>
				
				</div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>

				<div style="width:100%;height:1px;background:gray;float:left;"><span></span></div>
				<div style="width:100%;height:2px;background:#ffffff;float:left;"><span></span></div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>
				<br/>



				<div style="width:30px;height:30px;float:left;">5</div>
				<div style="width:600px;float:left;">
					거주지역<br>
					<div style="width:100%;height:5px;float:left;"><span></span></div>
							<select name="wr_sido" OnChange="changeRegion(fwrite)" onchange="$('#page_changed').val('1');"></select>
							<select name="wr_gugun" onchange="$('#page_changed').val('1');"></select>
							<script language="javascript">
							<!--
							// php 변수 wr_sido와 wr_gugun에 저장된 값을 기본 선택값으로 초기화한다.
							// wr_sido와 wr_gugun에 저장된 값이 없으면 첫 항목으로 초기화한다.
							var swr_sido = "<?=$row[1]?>"; // php 변수를 자바스크립트 변수로 저장 - 현재 선택된 시도.
							var swr_gugun = "<?=$row[2]?>"; // php 변수를 자바스크립트 변수로 저장 - 현재 선택된 시군구.
							initRegion();
							changeRegion(fwrite);
							-->
							</script>

				
				</div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>

				<div style="width:100%;height:1px;background:gray;float:left;"><span></span></div>
				<div style="width:100%;height:2px;background:#ffffff;float:left;"><span></span></div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>
				<br/>


				<div style="width:30px;height:30px;float:left;">5</div>
				<div style="width:600px;float:left;">
					자기소개<br>
					<div style="width:100%;height:5px;float:left;"><span></span></div>

					<textarea name="member_introduce" style="width:595px;height:118px;" onchange="$('#page_changed').val('1');"><? echo $row[5];?></textarea><br>
				
				</div>

				<div style="width:100%;height:15px;float:left;"><span></span></div>

				<div style="width:100%;height:1px;background:gray;float:left;"><span></span></div>
				<div style="width:100%;height:2px;background:#ffffff;float:left;"><span></span></div>

				<div style="width:100%;height:35px;float:left;"><span></span></div>




				<input type='hidden' id='img_changed' name='img_changed' value='0'>
		
				
					
				
				
				
				<div style='width:100%;height:30px;padding-left:30px;float:left;'>
						<a  onclick="$('#page_changed').val('0'); fwrite.submit();" style="cursor:pointer"><img src='./img/ndd_talk_save.png' border="0"></a>&nbsp;<a style='cursor:pointer;' onclick='history.back();'><img src='./img/ndd_talk_cancel.png' border="0"></a>
						
				</div>
				
				
				</form>
			
			</div>
			<? include "footer.php";?>		
		</div>

		
		<iframe src='' name='ifr_temp' style='display:none;'></iframe>



	</div>
 </body>
</html>
